/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apus.persistence.memory;

import apus.entity.Subscriber;
import apus.persistence.SubscriberDAO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author  Maxim Vasilevsky
 * @author  Roman Dyatkovsky
 * @since APUS v0.2
 * @see AbstractMemoryDAO
 * @see SubscriberDAO
 */
public abstract class MemorySubscriberDAO<TypeEn extends Subscriber> extends AbstractMemoryDAO<TypeEn> implements SubscriberDAO<TypeEn>{
    
    @Override
    protected abstract Map <Integer,TypeEn> getDataSource();
    
    @Override
    protected abstract Integer getAndIncreaseCounter();
            
    @Override
    public List<TypeEn> readByName(String name, int type) {
        List <TypeEn> list = new ArrayList<>();
        for (TypeEn ent: getDataSource().values()){
            if (ent.getName().indexOf(name)!=-1){
                list.add(ent);
            }
        }
        return list;
    }
       
}